/*
 * Copyright 2011 derek.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aocore.item;

/**
 *
 * @author derek
 */
public enum ItemAction
{
    AddToGround(0),
    /// <summary>
    /// Only sent if item goes to cursor (packet 0x0A removes items from ground...)
    /// </summary>
    GroundToCursor(1),
    DropToGround(2),
    OnGround(3),
    PutInContainer(4),
    RemoveFromContainer(5),
    Equip(6),
    /// <summary>
    /// Sent for the equipped item when changing from a two handed weapon to a single handed weapon or vice versa.
    /// <para>The item must be equipped on the "empty" hand or a regular SwapBodyItem will be sent instead.
    /// If currently wearing a two handed weapon, the empty hand means the left hand.
    /// The result will be the new item being equipped and the old going to cursor.</para>
    /// </summary>
    IndirectlySwapBodyItem(7),
    Unequip(8),
    SwapBodyItem(9),
    AddQuantity(0x0A),
    AddToShop(0x0B),
    RemoveFromShop(0x0C),
    SwapInContainer(0x0D),
    PutInBelt(0x0E),
    RemoveFromBelt(0x0F),
    SwapInBelt(0x10),
    /// <summary>
    /// Sent for the secondary hand's item going to inventory when changing from a dual item setup to a two handed weapon.
    /// </summary>
    AutoUnequip(0x11),
    /// <summary>
    /// Item on cursor when entering game.
    /// <para>Also sent along with a 0x9d type 0x08 packet when unequipping merc item.</para>
    /// </summary>
    ToCursor(0x12),
    ItemInSocket(0x13),
    UNKNOWNx14(0x14),
    /// <summary>
    /// When inserting item in socket, for each potion that drops in belt when lower one is removed, etc.
    /// </summary>
    UpdateStats(0x15),
    UNKNOWNx16(0x16),
    WeaponSwitch(0x17);

    private final int id;

    private ItemAction(int id)
    {
        this.id = id;
    }

    public int getId()
    {
        return id;
    }

    public static ItemAction valueOf(int id) throws IllegalArgumentException
    {
        for (ItemAction itemAction : values())
        {
            if (itemAction.getId() == id)
            {
                return itemAction;
            }
        }

        throw new IllegalArgumentException(id + " is not a valid ItemAction");
    }
}
